package mapping

import (
	"pay/model"
	"pay/model/entity"
	"pay/utils/bitmap"
)

// FeePlanGroupsEntityToDto entity data transfer
func FeePlanGroupsEntityToDto(feePlanGroups []*entity.FeePlanGroup) []*model.FeePlanGroupInfo {
	out := make([]*model.FeePlanGroupInfo, 0, len(feePlanGroups))
	for _, c := range feePlanGroups {
		out = append(out, FeePlanGroupEntityToDto(c))
	}
	return out
}

// FeePlanGroupEntityToDto entity data transfer
func FeePlanGroupEntityToDto(e *entity.FeePlanGroup) *model.FeePlanGroupInfo {

	data := &model.FeePlanGroupInfo{

		Id: e.Id,

		Name: e.Name,

		Remark: e.Remark,

		FeePlanIds: e.FeePlanIds,

		FeePlanDetail: e.FeePlanDetail,

		Def: e.Def,

		Enable: e.Enable,

		CreatedAt: e.CreatedAt,

		UpdatedAt: e.UpdatedAt,
	}

	if bs, err := bitmap.FromString(e.BitmapEbikeIds); err == nil {
		data.EbikeIds = bs.ToArray()
	}

	return data
}
